package com.misspao.lottery.controller;

import com.misspao.lottery.commen.ResultInfo;
import com.misspao.lottery.model.EmployeeAndPrizeVO;
import com.misspao.lottery.service.LotteryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>Title: </p>
 * <p>Company:misspao </p>
 *
 * @author: buwenmin
 * @Date: Create in 13:40 2018/1/30
 * @Description:
 */
@RestController()
@RequestMapping("/lotty")
@Api("抽奖接口")
public class LotteryController {
    @Autowired
    private LotteryService lotteryService;
    @GetMapping("validate")
    @ApiOperation("验证手机号码")
    @CrossOrigin(origins = "*",maxAge = 3600)
    public ResultInfo validatePhonenum(String phonenum,String username){
      ResultInfo info  = lotteryService.validatePhoneNum(phonenum,username);
        return info;
    }
    @GetMapping("getPrize")
    @ApiOperation("获取奖品")
    @CrossOrigin(origins = "*",maxAge = 3600)
    public ResultInfo getPrize(String phonenum){
        ResultInfo prizeInfo = lotteryService.getPrize(phonenum);
        return prizeInfo;

    }
    @GetMapping("initPrize")
    @ApiOperation("获取奖品")
    @CrossOrigin(origins = "*",maxAge = 3600)
    public ResultInfo initPrize(){
        ResultInfo info =  lotteryService.initPrize();
        ResultInfo info1 = lotteryService.initEmployee();
        return ResultInfo.success("更新初始化成功");
    }

}
